/*
 * RawMap Map Editor
 * Copyright 2010 RawMap developers (see AUTHORS file)
 *
 * This file is part of RawMap.
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the Free
 * Software Foundation; either version 2 of the License, or (at your option)
 * any later version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
 * more details.
 *
 * You should have received a copy of the GNU General Public License along with
 * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
 * Place, Suite 330, Boston, MA 02111-1307, USA.
 */

#ifndef WINDOW_H
#define WINDOW_H

#include <QWidget>
#include <QSystemTrayIcon>

#ifdef WIN32
  #define _WIN32_WINNT 0x0500
  #define WINVER 0x0500
  #include <windows.h>
#endif

#ifdef WIN32

#endif

class QMenu;
class QAction;

namespace Ui {
  class Window;
}

class Window : public QWidget {
  Q_OBJECT
public:
  Window(QWidget *parent = 0);
  ~Window();

  QSize sizeHint();

#ifdef WIN32
public slots:
  void updateAlpha();
  void setLayered();
#endif

protected:
  void changeEvent(QEvent *e);
  void closeEvent(QCloseEvent *e);

#ifdef WIN32
  void mouseMoveEvent(QMouseEvent *event);
  void mousePressEvent(QMouseEvent *event);
  void paintEvent(QPaintEvent *event);
  QPixmap drawCtrl(QWidget * widget);
  QRegion childRegion;
#endif

private slots:
  void hideWindow();
  void restoreWindow();
  void iconActivated(QSystemTrayIcon::ActivationReason reason);

private:
  void createActions();
  void createTrayIcon();

  Ui::Window *ui;

  QAction *hideAction;
  QAction *restoreAction;
  QAction *quitAction;

  QSystemTrayIcon *trayIcon;
  QMenu *trayIconMenu;

  QPixmap widgetMask;

#ifdef WIN32
  QPoint dragPosition;
  BYTE alpha;
#endif
};

#endif // WINDOW_H
